package com.theaf.basemodule.common.model;

import com.theaf.core.annotation.FieldCn;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

/**
 * @Author:songwenke
 * @Description: 岗位
 * @Date:create in 14:49 2017/12/21
 * @Modified By:
 **/
@Entity
@Table(name = "sys_position")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SysPosition {
    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.SEQUENCE,generator = "user_id_req")
    @SequenceGenerator(name = "user_id_req", sequenceName = "sys_req")
    private Long id;

    /**
     * 业务板块,见字典
     */
    @Column(name = "org_type")
    @FieldCn(value = "机构类型")
    private String orgType;

    /**
     * 名称
     */
    @Column(name = "name")
    @FieldCn(value = "名称")
    private String name;

    /**
     * 备注
     */
    @Column(name = "remark")
    @FieldCn(value = "备注")
    private String remark;

    /**
     * 创建者
     */
    @Column(name = "creater")
    @FieldCn(value = "创建者")
    private String creater;

    /**
     * 创建时间
     */
    @Column(name = "create_time")
    @FieldCn(value = "创建时间")
    private Date createTime;

    /**
     * 修改者
     */
    @Column(name = "updater")
    @FieldCn(value = "修改者")
    private String updater;

    /**
     * 修改时间
     */
    @Column(name = "update_time")
    @FieldCn(value = "修改时间")
    private Date updateTime;

    @Column(name = "order_no")
    @FieldCn(value = "排序号")
    private Integer orderNo;

    @Column(name = "liablility")
    @FieldCn(value = "是否责任岗位")
    private Boolean liablility;

    @Column(name = "org_range")
    @FieldCn(value = "机构范围")
    private Long orgRange;

    @ManyToMany(fetch=FetchType.LAZY)
    @JoinTable(name="sys_pos_auth",
            joinColumns=@JoinColumn(name="pos_id"),
            inverseJoinColumns=@JoinColumn(name="res_id"))
    private List<SysResource> resources;

    public SysPosition(Long id){
        this.id=id;
    }

}
